package com.iris.egrant.dao.proposal;

import com.iris.egrant.model.proposal.ProposalCachedExtend;
import com.iris.egrant.orm.hibernate.HibernateDao;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository
@Transactional
public class ProposalCachedExtendDao
        extends HibernateDao<ProposalCachedExtend, Long> {
    public ProposalCachedExtend getPrpInfo(Long posCode) {
        /* 29 */
        return (ProposalCachedExtend) findUniqueBy("posCode", posCode);
    }


    public void save(ProposalCachedExtend prpCachedExtend) {
        /* 39 */
        super.save(prpCachedExtend);
    }


    public void addElement(Long posCode, String status) {
        /* 49 */
        String node = "<prp_status>" + status + "</prp_status>";
        /* 50 */
        String nodeExistSql = " select Existsnode(t.prp_xml, 'data/proposal/prp_status') as nodeCount  from proposal_cached_extend t where t.pos_code = " + posCode;
        /* 51 */
        String nodeCount = getSessionFactory().getCurrentSession().createSQLQuery(nodeExistSql).list().get(0).toString();
        /* 52 */
        if ("0".equals(nodeCount)) {
            /* 53 */
            String addNodeSql = "update proposal_cached_extend t set t.prp_xml = APPENDCHILDXML(t.prp_xml, '/data/proposal',  sys.xmlType.createXML('" + node + "'))  where t.pos_code = " + posCode;
            /* 54 */
            getSessionFactory().getCurrentSession().createSQLQuery(addNodeSql).executeUpdate();
        } else {

            /* 57 */
            String alterNodeSql = "update proposal_cached_extend t set t.prp_xml = updatexml(t.prp_xml, '/data/proposal/prp_status', '" + node + "') where t.pos_code = " + posCode;
            /* 58 */
            getSessionFactory().getCurrentSession().createSQLQuery(alterNodeSql).executeUpdate();
        }
    }
}


/* Location:              D:\文件kjt\WEB-INF\lib\egrant-code-2.2.20240205.1659.jar!\com\iris\egrant\dao\proposal\ProposalCachedExtendDao.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       1.1.3
 */